package com.baosight.sczx.zm.ca.service;

import java.util.Calendar;
import java.util.HashMap;

import com.baosight.iplat4j.core.ei.EiInfo;
import com.baosight.iplat4j.ep.ServiceEPBase;
import com.baosight.sczx.common.zm.Utils;
import com.baosight.sczx.common.zm.basetools.StaticTools;
import com.baosight.sczx.zm.ca.domain.VZMCA03;

public class ServiceZMCA02 extends ServiceEPBase{
	
	public EiInfo initLoad(EiInfo inInfo) {
		return inInfo;//return this.query(inInfo);
	}

	public EiInfo queryByIndex(EiInfo inInfo) {
		VZMCA03 m = new VZMCA03();
		
		//设置查询昨天计划量相关的参数，为了调用ZMCA03.queryByIndex，随便设一下就好了
		StaticTools.setQueryParameters(inInfo, "fdMonthOfYesterday",1, true);
		StaticTools.setQueryParameters(inInfo, "fdDaysOfMonth", 30, true);
		//PlanType必须是"采煤计划"
		String PlanType = "采煤计划";
		StaticTools.setQueryParameters(inInfo, "PlanType", PlanType, true);
		
		EiInfo outInfo = super.query(inInfo, "ZMCA03.queryByIndex", m);	
		int cnt = Utils.queryNumber(dao, "ZMCA03.queryEmpCount", new HashMap<String, String>());
		outInfo.set("empCount", cnt);
		
		Calendar currentTime = Calendar.getInstance(); 
		inInfo.set("month", ""+(currentTime.get(Calendar.MONTH)+1));
		inInfo.set("year", ""+currentTime.get(Calendar.YEAR));
		return outInfo;
	}

	public EiInfo queryByChart(EiInfo inInfo) {
		VZMCA03 m = new VZMCA03();
		
		String PlanType = "采煤计划";
		StaticTools.setQueryParameters(inInfo, "PlanType", PlanType, true);
		inInfo.addBlock(Utils.generateOutBlock("queryByChart", m, inInfo, "ZMCA03.queryByChart", false));

		Calendar currentTime = Calendar.getInstance(); 
		inInfo.set("month", ""+(currentTime.get(Calendar.MONTH)+1));
		inInfo.set("year", ""+currentTime.get(Calendar.YEAR));

		//HashMap<String, String> params = new HashMap<String, String>();
		int cnt = Utils.queryNumber(dao, "ZMCA03.queryEmpCount", new HashMap<String, String>());
		inInfo.set("empCount", cnt);
		return inInfo;
	}
	
}
